package com.mvc.util;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import com.mvc.config.XmlBean;

/**
 * mvc配置解析器
 * @author asus
 *
 */

public class XmlParser {
	
	public static XmlBean parser(String url) {
		SAXReader reader = new SAXReader();
		Document document = null;
		XmlBean xmlBean = new XmlBean();
		try {
			document = reader.read(url);
			Element root = document.getRootElement();
			
			//解析扫描包
			Element sacnPkg = root.element("scan-pkg");
			xmlBean.setScanPkg(sacnPkg.getText());
			
		} catch (DocumentException e) {
			e.printStackTrace();
		}
		return xmlBean;
	}
	
	public static void main(String[] args) {
		parser("D:\\my\\workspace\\mvc\\src\\main\\webapp\\WEB-INF\\mvc-config.xml");
	}
}
